/**
 * 21/dic/2011 - fabio.melillo@gmail.com
 */
package test.hide;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.widget.Toast;

/**
 * @author fabio
 * 
 */
public class CallInBackground extends AsyncTask<String, Object, Object> {

	private ProgressDialog dialog;
	private Activity activity;
	
	public CallInBackground(Activity activity){
		this.activity=activity;
	}

	@Override
	protected void onPreExecute() {
		dialog = ProgressDialog.show(activity, "", "Calling. Please wait...",
				true);
	}


	@Override
	protected void onPostExecute(Object obj) {
		dialog.dismiss();
	}

	@Override
	protected Object doInBackground(String... num) {
		Intent intent=new Intent(Intent.ACTION_CALL);
		Uri phoneTo=Uri.parse("tel: "+num[0]);
		intent.setData(phoneTo);
		activity.startActivityForResult(intent, Activity.RESULT_OK);
		return null;
	}
	
}
